/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function initPendientesGrid(){
    $("#misautos_grid").jqGrid({
        url:'getAutosLista.do',
        datatype: "json",
        width:900,
 colNames:['Estatus','Marca','Auto','Modelo','Color','Numero Economico',
        'Serie','Fecha factura','Precio','Opciones'],
        colModel:[
        {
            name:'statusid',
            index:'statusid',
            sortable: true, 
             editable: true,       
            editoptions:{readonly: true},        
            width:55
        },

        {
            name:'marca',
            index:'marca', 
             editoptions:{readonly: true},
            sortable: true,
            editable: true,            
            width:90
        },

        {
            name:'auto',
            index:'auto',
            sortable: true, 
             editrules: { required: true},
             editable: true,    
            width:100
        },

        {
            name:'modelo',
            index:'modelo', 
            sortable: true,
             editable: true,   
              editrules: { required: true},
            width:100, 
            align:"right"
        },
        
        {
            name:'colorexterior1',
            index:'colorexterior1',
            sortable:true, 
             editable: true, 
              editrules: { required: true},
            width:100, 
            align:"rigth"
        },
        

        {
            name:'noeconomico',
            index:'noeconomico',
            sortable: true, 
            width:120, 
             editrules: { required: true},
             editable: true,    
            align:"right"
        },


        {
            name:'serie',
            index:'serie',
            sortable: true, 
            width:80, 
             editrules: { required: true, email: true},
             editable: true,    
            align:"right"
        },


        {
            name:'fechafactura',
            index:'fechafactura',
            sortable: true, 
            width:80, 
             editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        },


        {
            name:'precio',
            index:'precio',
            sortable: true, 
            width:80,
              editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        },
                {
            name:'actions',
            index:'actions',
            sortable: false, 
            width:80, 
            
            align:"center"
        } 		
  
        ],
        /*ondblClickRow: function(precio, amount, total){
                $( "#dialog-confirm" ).dialog({  
                     modal: true,
                     resizable: true,               
                      height: 600,
                      width: 1000,
                      position: 'center',
                      zIndex: 10000 

                   });
                   dwrService.getAutoDetail(function(data)
                        {
                               dwr.util.setValue('detail', data,{
                                    escapeHtml:false
                               });
                   });
        },*/
        rowNum:10,
        rowList:[10,20,30],
        pager: '#autos_pager',
        sortname: 'precio',
        viewrecords: true,
        sortable: true,
        sortorder: "desc",
        multiselect: false,
        caption:"Mis Autos Asignados",
        loadonce : false,
        rowTotal: 'total',
        records:'records',
        jsonReader: {
            repeatitems: false,
            id: "precio"
        }, 
        gridComplete: function(){
 	  
            var ids =$("#misautos_grid").jqGrid('getDataIDs');
	  
            for(var i=0;i < ids.length;i++){
                var precio_ = ids[i]; 
                
                icon2= " <img src='img/infoicon.png'alt='Ver auto' title='Aceptar' height='16' onclick=\"detail('"+precio_+"',1);\" width='16'  />";
                //icon3= " <img src='img/icon2.png' alt='Rechazar' title='Rechazar' height='18' onclick=\"changeStatusSolicitudAcceso('"+precio_+"',2);\" width='18'  />";
                $("#misautos_grid").jqGrid('setRowData',ids[i],{
                    actions:icon2//+icon3
                }); 
            }
 
        }
    });
    $("#misautos_grid").jqGrid('navButtonAdd','#autos_pager',{
        edit:true,
        add:true,
        view :true,
        del:true,
    },{},{},{closeAfterEdit:true},{} );

}

var myDelOptions = {
            
    onclickSubmit: function(rp_ge, rowid) {
                      
       // alert("The row with rowid="+rowid+" will be deleted");
        
        $("#misautos_grid").delRowData(rowid);
                        

        //                jQuery("#grid_id").jqGrid('saveRow',rowid, false);

        return true;
    },
    url:'solicitud.do?action=del'
//,  processing:true
};

function initAutorizadosGrid(){
    
    $("#misautos_grid").jqGrid({
        url:'getAutosLista.do?type=1',
        editurl:'solicitud.do?action=edit',
        datatype: "json",
        width:1000,
     
        colNames:['Estatus','Marca','Auto','Modelo','Color','Numero Economico',
        'Serie','Fecha factura','Precio'],
        colModel:[{
            name:'estatus',
            index:'estatus',
            sortable: true, 
            editable: true,       
            editoptions:{readonly: true},        
            width:55
        },

        {
            name:'marca',
            index:'marca', 
             editoptions:{readonly: true},
            sortable: true,
            editable: true,            
            width:90
        },

        {
            name:'auto',
            index:'auto',
            sortable: true, 
             editrules: { required: true},
             editable: true,    
            width:100
        },

        {
            name:'modelo',
            index:'modelo', 
            sortable: true,
             editable: true,   
              editrules: { required: true},
            width:100, 
            align:"right"
        },
        
        {
            name:'colorexterior1',
            index:'colorexterior1',
            sortable:true, 
             editable: true, 
              editrules: { required: true},
            width:100, 
            align:"rigth"
        },
        

        {
            name:'noeconomico',
            index:'noeconomico',
            sortable: true, 
            width:120, 
             editrules: { required: true},
             editable: true,    
            align:"right"
        },


        {
            name:'serie',
            index:'serie',
            sortable: true, 
            width:80, 
             editrules: { required: true, email: true},
             editable: true,    
            align:"right"
        },


        {
            name:'fechafactura',
            index:'fechafactura',
            sortable: true, 
            width:80, 
             editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        },


        {
            name:'precio',
            index:'precio',
            sortable: true, 
            width:80,
              editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        }		
           		
        ],
        rowNum:10,
        rowList:[10,20,30],
        pager: '#generalistas_aut_pager',
        sortname: 'folio',
        viewrecords: true,
        sortable: true,
        multiselect: true,
        sortorder: "desc",
        caption:"Mis Autos Asignados",
        loadonce : false,
        rowTotal: 'total',
        records:'records',
        jsonReader: {
            repeatitems: false,
            id: "folio"
   
        },
        gridComplete: function(){
 	  
            var ids =$("#misautos_grid").jqGrid('getDataIDs');
	  
//            for(var i=0;i < ids.length;i++){
//                var cl = ids[i]; 
//                icon1 = " <img src='img/icon1.png' alt='alta' height='16' width='16' onclick=\"test('"+cl+"');\" />";					 
//                $("#generalistas_aut_grid").jqGrid('setRowData',ids[i],{
//                    actions:icon1
//                }); 
//            }
 
        }
    });
    $("#misautos_grid").jqGrid('navGrid','#autos_pager',{
        edit:false,
        add:false,
        del:false
    },{closeAfterEdit:false},{},myDelOptions,{});  
    
    
 
   
       
}